package com.bosssoft.permission.centre.service;


import com.bosssoft.permission.centre.entity.Node;
import com.bosssoft.permission.centre.pojo.dto.pcp.RoleDTO;
import com.bosssoft.permission.centre.pojo.dto.pcp.RoleResourceDTO;
import com.bosssoft.permission.centre.pojo.dto.pcp.UserDTO;
import com.bosssoft.permission.centre.pojo.dto.pcp.UserRoleDTO;
import com.bosssoft.permission.centre.pojo.query.RoleQuery;
import com.bosssoft.permission.centre.pojo.query.UserQuery;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import java.util.List;
/**
 * @Author: wang
 * @Time: 2022/3/18
 */
public interface RoleService {

    /**
     * @param: 给多个角色分配多个资源
     * @return: 成功则true
     * @see
     * @since
     */
    @Transactional
    Boolean assignResource(RoleResourceDTO roleResourceDTO);

    @Transactional
    Boolean assignUser(UserRoleDTO userRoleDTO);

    /**
     * 查询角色所拥有的所有资源
     * @return Node
     */
    List<Node> queryResourceByRoleId(long roleId);

    /**
     * 查询公司节点
     * @return Node
     */
    List<Node> selectCompany();

    /**
     * 验证是否已经存在角色
     * @return Node
     */
    boolean haveRole(@RequestBody @Valid RoleDTO roleDTO);

    /**
     * @param: 角色DTO
     * @return: 成功则true
     * @see
     * @since
     */
    Boolean add(@RequestBody @Valid RoleDTO roleDTO);


    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    Boolean remove(Long id, Long version);


    /**
     * @param:角色DTO
     * @return:
     * @see
     * @since
     */
    RoleDTO modify(RoleDTO roleDTO);

    /**
     * @param:角色DTO
     * @return:
     * @see
     * @since
     */
    List<RoleDTO> commonQuery(RoleQuery roleQuery);

    /**
     * @param: 角色id
     * @return: RoleDTO
     * @see
     * @since
     */
    RoleDTO queryById(Long id);

    /**
     *  复制一条和RoleDTO 一样的记录并且将值返回前端
     * @param:
     * @return:
     * @see
     * @since
     */
    RoleDTO copy(Long id);
    /**
     *  批量删除
     * @param:
     * @return:
     * @see
     * @since
     */
    @Transactional
    Boolean batchRemove(RoleDTO[] roleDTOS);

    /**
     * @param:用户DTO
     * @return:
     * @see
     * @since
     */
    List<UserDTO> commonQueryUser(UserQuery userQuery);

    RoleDTO queryUserResource(Long id);
}
